
import Vue from 'vue'
import Vuex from 'vuex'

import user from './global/user'
import exam from './global/exam'

import pages from './pages'

Vue.use(Vuex)

// https://github.com/vuejs/vuex/tree/dev/examples/shopping-cart

const initPlugin = store => {
	Object.keys(store._actions).forEach(p => {
		if (p.search(/init$/) >= 0){
			store.dispatch(p);
		}
	});
}

let store = new Vuex.Store({
	modules: {
		user, exam, 
		pages,
	},
	plugins: [initPlugin],
});



export default store;